﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Models;
namespace DAL
{
    public class HyfAddDAL
    {
#pragma warning disable CS0618 // “ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings”
        public static string conn = ConfigurationSettings.AppSettings["con"].ToString();
#pragma warning restore CS0618 // “ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings”
        public static int addRecord(HyfResultOrder ho)
        {
            SqlParameter[] sp = new SqlParameter[] {
                new SqlParameter("@version",ho.version),
                new SqlParameter("@hicardMerchNo",ho.hicardMerchNo),
                new SqlParameter("@payType",ho.payType),
                new SqlParameter("@merchOrderNo",ho.merchOrderNo),
                new SqlParameter("@amount",ho.amount),
                new SqlParameter("@createTime",ho.createTime),
                new SqlParameter("@payTime",ho.payTime),
                new SqlParameter("@cardno",ho.cardno),
                new SqlParameter("@hicardOrderNo",ho.hicardOrderNo),
                new SqlParameter("@respCode",ho.respCode),
                new SqlParameter("@respMsg",ho.respMsg),
                new SqlParameter("@buyerId",ho.buyerId),
                new SqlParameter("@isCredit",ho.isCredit),
                new SqlParameter("@channelOrderNo",ho.channelOrderNo),
                new SqlParameter("@sign",ho.sign),
            };
         
            string sqlstr = "if not exists(select cardno from Hyfrecord where hicardOrderNo=@hicardOrderNo) insert into dbo.Hyfrecord values(@version,@hicardMerchNo,@payType,@merchOrderNo,@amount,@createTime,@payTime,@cardno,@hicardOrderNo,@respCode,@respMsg,@buyerId,@isCredit,@channelOrderNo,@sign)";
            return SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sqlstr, sp);
        }
        public static DataTable getall()
        {
            string sqlstr = "select * from  HyfManager";

            return SqlHelper.ExecuteDataSet(conn, CommandType.Text, sqlstr).Tables[0];
        }
    }
}
